package com.example.quartzdemo.context;

/**
 * 任务常量
 */
public class TaskConst {

    /**
     * 任务分组
     */
    public enum GroupEnum {
        SYSTEM;
    }

    /**
     * 星期枚举
     */
    public enum DayOfWeekEnum {

        SUNDAY(1, "SUN"),

        MONDAY(2, "MON"),

        TUESDAY(3, "TUE"),

        WEDNESDAY(4, "WED"),

        THURSDAY(5, "THU"),

        FRIDAY(6, "FRI"),

        SATURDAY(7, "SAT");

        private final Integer code;

        private final String name;

        DayOfWeekEnum(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

        public Integer getCode() {
            return code;
        }

        public String getName() {
            return name;
        }

        /**
         * 根据code查询枚举
         */
        public static DayOfWeekEnum getByCode(Integer code) {
            for (DayOfWeekEnum value : DayOfWeekEnum.values()) {
                if (value.getCode().equals(code)) {
                    return value;
                }
            }
            return null;
        }

        /**
         * 根据name查询枚举
         */
        public static DayOfWeekEnum getByName(String name) {
            for (DayOfWeekEnum value : DayOfWeekEnum.values()) {
                if (value.getName().equals(name)) {
                    return value;
                }
            }
            return null;
        }
    }

}
